home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / getdraghilitecolor / drawcode.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  3.2 KB  |  126 lines

  1. /*
  2.     File:        DrawCode.c
  3.  
  4.     Contains:    This shows how to obtain the color that the Drag Manager uses to
  5.                 hilite regions when ShowDragHilite is called.  Check out GetDragHilite.c
  6.                 for the code.  
  7.  
  8.                 Please note this is only how it's done presently.  Since it is undocumented
  9.                 it can and will change in the future.
  10.  
  11.     Written by: Nitin Ganatra    
  12.  
  13.     Copyright:    Copyright © 1994-1999 by Apple Computer, Inc., All Rights Reserved.
  14.     
  15.                 You may incorporate this Apple sample source code into your program(s) without
  16.                 restriction. This Apple sample source code has been provided "AS IS" and the
  17.                 responsibility for its operation is yours. You are not permitted to redistribute
  18.                 this Apple sample source code as "Apple sample source code" after having made
  19.                 changes. If you're going to re-distribute the source, we require that you make
  20.                 it clear in the source that the code was descended from Apple sample source
  21.                 code, but that you've made changes.
  22.  
  23.     Change History (most recent first):
  24.                 8/6/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  25.                 
  26.  
  27. */
  28. #include <Windows.h>
  29. #include <QuickDraw.h>
  30. #include <TextUtils.h>
  31. #include <Fonts.h>
  32.  
  33. extern void SetupDragHiliteColor(WindowPtr);
  34. void DrawIt(WindowPtr win);
  35. pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin);
  36. void MyCreateNewWindow(void);
  37. void PreEventLoop(void);
  38. void DoUpdate(WindowPtr thisWindow);
  39. void PostEventLoop(void);
  40.  
  41.  
  42. /*-------------------------------------------------------------------------------------*/
  43.  
  44. void DrawIt(WindowPtr win)
  45. {
  46.     short         origFont, origSize;
  47.     
  48.     origFont = win->txFont;
  49.     origSize = win->txSize;
  50.     TextFont(kFontIDHelvetica);
  51.     TextFace(bold);
  52.     TextSize(14);
  53.  
  54.     SetupDragHiliteColor(win);
  55.     PaintRect(&(*win).portRect);
  56.     ForeColor(blackColor);
  57.  
  58.     MoveTo(10, 30);
  59.     DrawString("\pThis is the hilite color used for drags");
  60.  
  61.     TextFont(origFont);
  62.     TextSize(origSize);
  63.     TextFace(0);
  64. }
  65.  
  66.  
  67. /*-------------------------------------------------------------------------------------*/
  68.  
  69. pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin)
  70. {
  71. #pragma unused (pixelDepth, dFlags, theDevice)
  72.     GrafPtr        savePort;
  73.  
  74.     GetPort(&savePort);
  75.     SetPort((GrafPtr)theWin);
  76.  
  77.     DrawIt((WindowPtr)theWin);
  78.  
  79.     SetPort(savePort);
  80. }
  81.  
  82.  
  83. /*-------------------------------------------------------------------------------------*/
  84.  
  85. void MyCreateNewWindow(void)
  86. {
  87.     Rect winDimension;
  88.     
  89.     SetRect(&winDimension, 60, 60, 360, 160);
  90.     (void)NewCWindow(0L, &winDimension, "\pSample", true, noGrowDocProc,
  91.                             (WindowPtr)-1L, true, 0L);
  92. }
  93.  
  94.  
  95. /*-------------------------------------------------------------------------------------*/
  96.  
  97. void PreEventLoop(void)
  98. {
  99.     MyCreateNewWindow();
  100. }
  101.  
  102.  
  103. /*-------------------------------------------------------------------------------------*/
  104.  
  105. void DoUpdate(WindowPtr thisWindow)
  106. {
  107.     static DeviceLoopDrawingUPP    procForDeviceLoop = nil;
  108.  
  109.     SetPort(thisWindow);
  110.  
  111.     if ( procForDeviceLoop == nil )
  112.         procForDeviceLoop = NewDeviceLoopDrawingProc(DrawWindowContent);    
  113.     
  114.     BeginUpdate(thisWindow);
  115.     DeviceLoop(thisWindow->visRgn, procForDeviceLoop, (long)thisWindow, singleDevices);
  116.     EndUpdate(thisWindow);
  117. }
  118.  
  119.  
  120. /*-------------------------------------------------------------------------------------*/
  121.  
  122. void PostEventLoop(void)
  123. {
  124. }
  125.  
  126.